package lex.fractal.mandelbrotset;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

import org.lex.swing.Swings;


/**
 * In 1979, Polish mathematician Benoit Mandelbrot began to study a class of
 * fractals known as Julia sets. During this study, he discovered a fractal that
 * has since been named after him. The Mandelbrot set fractal is defined as the
 * set of all complex numbers c such that iterating z = z*z + c (where z is also
 * a complex number) does not escape to infinity.<br>
 * Use the following algorithm to recursively generate the Mandelbrot set:<br>
 * 1.For each point c on the complex plane, repeatedly evaluate z = z*z + c,
 * where z is initially 0. <br>
 * 2.Determine the distance between the new z and the set's 0 + 0i origin by
 * squaring z's real component, squaring z's imaginary component, adding both
 * squares together, and taking the square root of the sum. <br>
 * 3.If the distance exceeds 2, the point does not lie in the set and the loop
 * can end (for this point). Otherwise, keep iterating for at least 100 times.
 * When the last iteration completes for a given point, and the distance between
 * the point and the set's origin is still less than 2, display the point at the
 * corresponding (x, y) location on the screen.
 */
public class MandelbrotSet extends JPanel {
	private JLabel statusLabel = new JLabel("Level: 0");

	public static void main(String[] args) {
		Swings.show(new MandelbrotSet());
	}

	public MandelbrotSet() {
		super(new BorderLayout());
		this.add(new MSPane(statusLabel), BorderLayout.CENTER);
		this.add(statusLabel, BorderLayout.SOUTH);
	}
}
